package com.haois.mp.database.module.wxserver.rest;

import com.haois.mp.database.commom.enums.ApiResultEnum;
import com.haois.mp.database.module.common.daomain.BindState;
import com.haois.mp.database.module.offaccounts.service.UserFollowService;
import com.haois.mp.database.module.wxserver.util.MapUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Created by RuiHaoZ on 2018/3/25 23:43
 */
@RestController
@RequestMapping("/api/wxmp")
public class UserBindController {
    @Autowired
    private UserFollowService userFollowService;

    /**
     * @api {GET} /api/wxmp/bind/state 获取绑定状态
     * @apiGroup UserState
     * @apiName bindState
     * @apiDescription 获取公众号和小程序用户绑定状态
     * @apiParam {String} memberNums 编号列，以 "," 分割
     * @apiParam {String} sysType 1为小程序 0 为公众号
     * @apiParamExample {json} 请求样例：
     * GET /api/wxmp/bind/state
     * @apiSuccessExample {json} 返回样例:
     * {
     * <p>
     * }
     */
    @PostMapping(value = "/bind/state", params = {"memberNums","sysType"})
    public Map bindState(String memberNums,String sysType) {
        String[] memberNum = memberNums.split(",");
        List<BindState> bindState = userFollowService.getBindState(memberNum, sysType);
        Map map = MapUtil.createMap(ApiResultEnum.API_00.getCode(), "获取成功", bindState);
        return map;
    }

}
